package com.fy.utils;

import com.fy.common.config.AppConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class EmailCodeSend {

    @Autowired
    private AppConfig appConfig;
    /***打包需要发送的内容
     *
     * @param email
     * @param code
     * @return
     */
    public SimpleMailMessage packageMessage(String email,String code){
            SimpleMailMessage message=new SimpleMailMessage();
            message.setFrom("蜂云盒子注册中心 <2285114622@qq.com>"); // 设置发件人邮箱
        log.info("发件人邮箱:{}",appConfig.getSendUserEmail());
            message.setTo(email); // 设置收件人邮箱
            message.setSubject("验证码"); // 设置邮件主题
        message.setText("您的验证码为：<b>" + code + "</b>\n" +
                "请确保本人操作，在规定时间内完成验证！\n" +
                "<i>:@fwq fypan</i>");
        log.info("xxxx:{}",message);
        return message;
    }
}
